import 'package:flutter/material.dart';

class DkBottomNavigationBar extends BottomNavigationBar {
  final BottomNavigationBarOption bottomNavigationBarOption;

  DkBottomNavigationBar(this.bottomNavigationBarOption)
      : super(
          key: bottomNavigationBarOption.key,
          items: bottomNavigationBarOption.items,
          elevation: bottomNavigationBarOption.elevation,
          type: bottomNavigationBarOption.type,
          currentIndex: bottomNavigationBarOption.currentIndex,
          onTap: bottomNavigationBarOption.onTap,
          backgroundColor: bottomNavigationBarOption.backgroundColor,
          fixedColor: bottomNavigationBarOption.fixedColor,
          iconSize: bottomNavigationBarOption.iconSize,
          selectedFontSize: bottomNavigationBarOption.selectedFontSize,
          selectedItemColor: bottomNavigationBarOption.selectedItemColor,
          unselectedFontSize: bottomNavigationBarOption.unselectedFontSize,
          unselectedItemColor: bottomNavigationBarOption.unselectedItemColor,
          showSelectedLabels: bottomNavigationBarOption.showSelectedLabels,
          showUnselectedLabels: bottomNavigationBarOption.showUnselectedLabels,
        );
}

class BottomNavigationBarOption {
  Key key;
  List<BottomNavigationBarItem> items;
  ValueChanged<int> onTap;
  int currentIndex;
  double elevation = 8.0;
  BottomNavigationBarType type;
  Color fixedColor;
  Color backgroundColor;
  double iconSize = 24.0;
  Color selectedItemColor;
  Color unselectedItemColor;
  double selectedFontSize = 14.0;
  double unselectedFontSize = 12.0;
  bool showSelectedLabels = true;
  bool showUnselectedLabels;
  FloatingActionButton floatingActionButton;
  FloatingActionButtonLocation floatingActionButtonLocation;

  BottomNavigationBarOption.withDefault(
    this.items, {
    this.key,
    this.onTap,
    this.currentIndex = 0,
    this.elevation = 0.0,
    this.type = BottomNavigationBarType.fixed,
    this.fixedColor,
    this.backgroundColor,
    this.iconSize,
    this.selectedItemColor,
    this.unselectedItemColor,
    this.selectedFontSize,
    this.unselectedFontSize,
    this.showSelectedLabels,
    this.showUnselectedLabels,
    this.floatingActionButton,
    this.floatingActionButtonLocation,
  }) {
    items ??= [
      BottomNavigationBarItem(
        icon: Icon(Icons.hourglass_empty),
        title: Text(""),
      ),
      BottomNavigationBarItem(
        icon: Icon(Icons.hourglass_empty),
        title: Text(""),
      ),
    ];
    if (items.length < 2) {
      items.add(BottomNavigationBarItem(
        icon: Icon(Icons.hourglass_empty),
        title: Text(""),
      ));
    }
    if (currentIndex < 0 || currentIndex >= items.length) {
      currentIndex = 0;
    }
    if (null == elevation || elevation < 0) {
      elevation = 0.0;
    }
    if (iconSize == null || iconSize < 0.0) {
      iconSize = 24.0;
    }
    if (null != selectedItemColor && null != fixedColor) {
      fixedColor = null;
    }
    if (selectedFontSize == null || selectedFontSize < 0.0) {
      selectedFontSize = 14.0;
    }
    if (unselectedFontSize == null || unselectedFontSize < 0.0) {
      unselectedFontSize = 12.0;
    }
    showSelectedLabels ??= true;
  }
}
